import type { R, TableDataInfo } from '@/api/model/resultModel';
import type { SysProfitRuleForm, SysProfitRuleQuery, SysProfitRuleVo } from '@/api/system/model/profitRuleModel';
import { request } from '@/utils/request';

/**
 * 查询分佣规则列表
 * @param query 查询参数
 */
export function listProfitRule(query?: SysProfitRuleQuery) {
  return request.get<TableDataInfo<SysProfitRuleVo>>({
    url: '/system/profitRule/list',
    params: query,
  });
}

/**
 * 查询分佣规则详细
 * @param ruleId 主键
 */
export function getProfitRule(ruleId: string) {
  return request.get<R<SysProfitRuleVo>>({
    url: `/system/profitRule/${ruleId}`,
  });
}

/**
 * 新增分佣规则
 * @param data 表单数据
 */
export function addProfitRule(data: SysProfitRuleForm) {
  return request.post<R<void>>({
    url: '/system/profitRule',
    data,
  });
}

/**
 * 修改分佣规则
 * @param data
 */
export function updateProfitRule(data: SysProfitRuleForm) {
  return request.put<R<void>>({
    url: '/system/profitRule',
    data,
  });
}

/**
 * 删除分佣规则
 * @param ruleIds 主键串
 */
export function delProfitRule(ruleIds: string | Array<string>) {
  return request.delete<R<void>>({
    url: `/system/profitRule/${ruleIds}`,
  });
}
